﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Things.Common;
using LTP.Accounts.Bus;
namespace Things.Web.CropsProductProgress
{
    public partial class Modify : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    Guid ProductProgressID = new Guid(Request.Params["id"]);
                    ShowInfo(ProductProgressID);
                }
            }
        }

        private void ShowInfo(Guid ProductProgressID)
        {
            Things.BLL.CropsProductProgress bll = new Things.BLL.CropsProductProgress();
            Things.Model.CropsProductProgress model = bll.GetModel(ProductProgressID);
            this.lblProductProgressID.Text = model.ProductProgressID.ToString();
            this.txtProductProgressName.Text = model.ProductProgressName;
            this.txtProductProgressOrder.Text = model.ProductProgressOrder.ToString();
        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtProductProgressName.Text.Trim().Length == 0)
            {
                strErr += "加工过程名称不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtProductProgressOrder.Text))
            {
                strErr += "加工过程顺序格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            Guid ProductProgressID = new Guid(this.lblProductProgressID.Text);
            string ProductProgressName = this.txtProductProgressName.Text;
            int ProductProgressOrder = int.Parse(this.txtProductProgressOrder.Text);


            Things.BLL.CropsProductProgress bll = new Things.BLL.CropsProductProgress();
            Things.Model.CropsProductProgress model = bll.GetModel(ProductProgressID);
            if (model != null)
            {
                model.ProductProgressName = ProductProgressName;
                model.ProductProgressOrder = ProductProgressOrder;

                bll.Update(model);
                Things.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx");
            }
        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
